require(["common", "hash_routie", "coAjax", "queryString", "Cookies", "href"], function(jSouper, hash_routie, coAjax, QueryString, Cookies, href) {
    //用户名缓存
    App.set("$Cache.agent.login.name", Cookies.get("cache_bus_login_name"));

    queryString = new QueryString;
    App.set("$Event.agent.login", function(argument) {
        var login_data = App.get("$Cache.agent.login");
        coAjax.post(appConfig.user.sign_in_url + "?as_MA=true", login_data, function(agent) {
            console.log(agent.result);
            alert("success", "登录成功");
            var callbackUrl = queryString.get("cb_url");
            Cookies.set("cache_bus_login_name", login_data.name);
            if (callbackUrl) {
                href.jump(callbackUrl);
            } else {
                href.jump("/agent.html");
            };
        }, function(errorCode, errResponse, errorMsg) {
            alert("warn", errorMsg);
        });
    });
    App.set("$Event.agent.login.to_password_input", function() {
        App.set("$Cache.agent.login.is_focus_pwd", true);
        App.set("$Cache.agent.login.is_focus_pwd", false);
    });
});
